package com.fqgj.xjd.user.dao.impl;
import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.CollectionUtils;
import com.fqgj.xjd.user.dao.UserBehaviorDeviceShumeiDao;
import com.fqgj.xjd.user.entity.UserBehaviorDeviceShumeiEntity;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: zhangxingyun
* Date: 2017-07-23
* Time: 14:10:48.129
*/

@Repository
public class UserBehaviorDeviceShumeiDaoImpl extends AbstractBaseMapper<UserBehaviorDeviceShumeiEntity> implements UserBehaviorDeviceShumeiDao {
    @Override
    public UserBehaviorDeviceShumeiEntity selectByUserCode(String userCode) {
        return getSqlSession().selectOne(getStatement("selectByUserCode"), userCode);
    }

    @Override
    public List<UserBehaviorDeviceShumeiEntity> selectLatestByUserCodes(List<String> userCodes) {
        if (CollectionUtils.isEmpty(userCodes)) {
            return null;
        }
        return getSqlSession().selectList("selectLatestByUserCodes", userCodes);
    }

    @Override
    public List<UserBehaviorDeviceShumeiEntity> selectListByPage(Date endDate, Page page) {
        Map<String, Object> map = new HashMap<>();
        map.put("endDate", endDate);
        map.put("page", page);
        return getSqlSession().selectList(getStatement("selectListByPage"), map);
    }

    @Override
    public List<UserBehaviorDeviceShumeiEntity> selectByPage(Map<String, Object> map) {
        return getSqlSession().selectList(getStatement("selectByPage"), map);
    }

    @Override
    public Integer countAllEntities() {
        return getSqlSession().selectOne("countAllEntities");
    }

    @Override
    public void batchUpdate(List<UserBehaviorDeviceShumeiEntity> list) {
        getSqlSession().update("batchUpdate", list);
    }

    @Override
    public List<UserBehaviorDeviceShumeiEntity> selectNeedParseAppListDateByPage(long startId,int page) {

        Map<String, Object> map = new HashMap<>();
        map.put("startId", startId);
        map.put("page", page);
        return getSqlSession().selectList("selectNeedParseAppListDateByPage", map);
    }
}